import Vue from 'vue'
import VueRouter from 'vue-router'

//自动导入指定目录下面的文件
const moduleFn = require.context('./routes',false,/\.js$/)
const routes = moduleFn.keys().reduce((prev,curr) => {
  prev.push(moduleFn(curr).default)
  return prev
},[])

Vue.use(VueRouter)


const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
